package com.example.demo.singletonpattern;

/**
 * @author :xie
 * Email: 1487471733@qq.com
 * Date: 2018/9/7
 * Time: 11:18
 * Describe:
 * 采用双锁机制，安全且在多线程情况下能保持高性能
 */
public class DclSingle {

    private volatile static DclSingle singleton;
    private DclSingle (){

    }
    public static DclSingle getSingleton() {
        if (singleton == null) {
            synchronized (DclSingle.class) {
                if (singleton == null) {
                    singleton = new DclSingle();
                }
            }
        }
        return singleton;
    }
}
